<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="../assets/lib/layui/css/layui.css" />
  <link rel="stylesheet" href="../assets/css/edit.css" />
  <link rel="stylesheet" href="../assets/lib/cropper/cropper.css" />
</head>

<body>
  <!-- 面板区域 -->
  <div class="layui-card">
    <div class="layui-card-header">写文章</div>
    <div class="layui-card-body">
      <!-- 表单区域 -->
      <form class="layui-form" lay-filter="addArticle" id="formAddArticle" enctype="multipart/form-data">
        <!-- 文章标题 -->
        <div class="layui-form-item">
          <label class="layui-form-label">文章标题</label>
          <div class="layui-input-block">
            <input type="text" name="title" required lay-verify="required" placeholder="请输入标题" autocomplete="off"
              class="layui-input" />
          </div>
        </div>
        <!-- 文章类别 -->
        <div class="layui-form-item">
          <label class="layui-form-label">文章类别</label>
          <div class="layui-input-block" id="art_cate">
            <!-- 下拉框区域 -->
          </div>
        </div>
        <!-- 文章内容 -->
        <div class="layui-form-item">
          <label class="layui-form-label">文章内容</label>
          <div class="layui-input-block" style="height: 400px;">
            <textarea name="content" id="content"></textarea>
          </div>
        </div>
        
        <!-- 文章封面 -->
        <div class="layui-form-item">
          <label class="layui-form-label">文章封面</label>
          <div class="layui-input-block cropper-container">
            <!-- 隐藏域 -->
            <!-- <input type="hidden" name="cover_img" /> -->
            <!-- 文件选择框 -->
            <!-- 若图片设置name属性获取, 获取到的是整个图片而不是裁剪后的 -->
            <input type="file" id="fileCover" accept="image/jpeg,image/png,image/gif,image/bmp"
              style="display: none;" />
            <div class="cropper-box">
              <img id="image" src="../assets/images/sample2.jpg">
            </div>

            <div class="right-box">
              <div class="img-preview"></div>
              <button type="button" class="layui-btn layui-btn-danger" id="btnChooseCoverImage">选择封面</button>
            </div>
          </div>
        </div>
        <!-- 文章状态 -->
        <div class="layui-form-item">
          <label class="layui-form-label">文章状态</label>
          <div class="layui-input-block">
            <input type="radio" name="state" value="已发布" title="已发布">
            <input type="radio" name="state" value="草稿" title="草稿" checked>
          </div>
        </div>
        <!-- 按钮区域 -->
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit id="btnPublish">发布</button>
          </div>
        </div>
      </form>
    </div>
  </div>

  <!-- 文章分类列表的模板 -->
  <script type="text/html" id="selectArtCates">
    <select name="cate_id" lay-verify="required">
      <option value="">请选择文章类别</option>
      {{each data item}}
      <option value="{{item.Id}}">{{item.name}}</option>
      {{/each}}
    </select>
  </script>

  <script src="../assets/lib/layui/layui.all.js"></script>
  <script src="../assets/lib/template-web.js"></script>
  <script src="../assets/lib/jquery.js"></script>
  <script src="../assets/lib/tinymce/tinymce.min.js"></script>
  <script src="../assets/lib/tinymce/tinymce_setup.js"></script>
  <script src="../assets/lib/cropper/Cropper.js"></script>
  <script src="../assets/lib/cropper/jquery-cropper.js"></script>
  <script src="../assets/js/common.js"></script>
  <script src="../assets/js/edit.js"></script>
</body>

</html>